//#include<bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

typedef unsigned long long ull;
using namespace std;

typedef struct Person {
	long long money=0;
	int num=0;
	int code=0;
};

bool cmp(Person& p1, Person& p2) {
	if (p1.money > p2.money) {
		return true;
	}
	else if (p1.money == p2.money) {
		if (p1.num > p2.num) {
			return true;
		}
		else if (p1.num == p2.num) {
			if (p1.code < p2.code) {
				return true;
			}
		}
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<Person> vec(n+1);
	for (int i = 1;i <= n;i++) {
		vec[i].code = i;
	}

	for (int i = 1;i <= n;i++) {
		int k;
		cin >> k;
		for (int j = 0;j < k;j++) {
			int a;
			double b;
			cin >> a >> b;
			vec[a].money += b;
			vec[a].num++;
			vec[i].money -= b;
		}
	}
	sort(vec.begin() + 1, vec.end(), cmp);
	for (int i = 1;i <= n;i++) {
		printf("%d  %.2lf\n", vec[i].code, vec[i].money*1.0/100);
	}
	return 0;
}